//<my-matriculator - a simple tool for registering racers in a USAC cyclocross race>
//Copyright (C) <2011>  <Steven Rivers>

//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.

using System.ComponentModel;

namespace Registration.Model.Entities
{
    public class UsacRider : INotifyPropertyChanged
    {
        private int _license;
        public int License
        {
            get { return _license; }
            set
            {
                _license = value;
                OnPropertyChanged(new PropertyChangedEventArgs("License"));
            }
        }

        private string _lastname;
        public string LastName
        {
            get { return _lastname; }
            set
            {
                _lastname = value;
                OnPropertyChanged(new PropertyChangedEventArgs("LastName"));
            }
        }

        private string _firstname;
        public string FirstName
        {
            get { return _firstname; }
            set
            {
                _firstname = value;
                OnPropertyChanged(new PropertyChangedEventArgs("FirstName"));
            }
        }
        private string _city;
        public string City
        {
            get { return _city; }
            set
            {
                _city = value;
                OnPropertyChanged(new PropertyChangedEventArgs("City"));
            }
        }
        private string _state;
        public string State
        {
            get { return _state; }
            set
            {
                _state = value;
                OnPropertyChanged(new PropertyChangedEventArgs("State"));
            }
        }

        private string _gender;
        public string Gender
        {
            get { return _gender; }
            set
            {
                _gender = value;
                OnPropertyChanged(new PropertyChangedEventArgs("Gender"));
            }
        }
        private string _racingage;
        public string RacingAge
        {
            get { return _racingage; }
            set
            {
                _racingage = value;
                OnPropertyChanged(new PropertyChangedEventArgs("RacingAge"));
            }
        }

        private string _expdate;
        public string ExpDate
        {
            get { return _expdate; }
            set
            {
                _expdate = value;
                OnPropertyChanged(new PropertyChangedEventArgs("ExpDate"));
            }
        }

        private string _club;
        public string Club
        {
            get { return _club; }
            set
            {
                _club = value;
                OnPropertyChanged(new PropertyChangedEventArgs("Club"));
            }
        }

        private string _team;
        public string Team
        {
            get { return _team; }
            set
            {
                _team = value;
                OnPropertyChanged(new PropertyChangedEventArgs("Team"));
            }
        }

        private string _ncaa;
        public string Ncaa
        {
            get { return _ncaa; }
            set
            {
                _ncaa = value;
                OnPropertyChanged(new PropertyChangedEventArgs("NCAA"));
            }
        }

        private string _crosscategory;
        public string CrossCategory
        {
            get { return _crosscategory; }
            set
            {
                _crosscategory = value;
                OnPropertyChanged(new PropertyChangedEventArgs("CrossCategory"));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged(PropertyChangedEventArgs e)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, e);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof (UsacRider)) return false;
            return Equals((UsacRider) obj);
        }

        public UsacRider(int license, string lastname, string firstname, string city,
                         string state, string gender, string age, string expdate, string club, string team,
                         string ncaa, string cat)
        {
            License = license;
            LastName = lastname;
            FirstName = firstname;
            City = city;
            State = state;
            Gender = gender;
            RacingAge = age;
            ExpDate = expdate;
            Club = club;
            Team = team;
            Ncaa = ncaa;
            CrossCategory = cat;
        }

        public bool Equals(UsacRider other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return other._license == _license && Equals(other._lastname, _lastname) && Equals(other._firstname, _firstname) && Equals(other._city, _city) && Equals(other._state, _state) && Equals(other._gender, _gender) && Equals(other._racingage, _racingage) && Equals(other._expdate, _expdate) && Equals(other._club, _club) && Equals(other._team, _team) && Equals(other._ncaa, _ncaa) && Equals(other._crosscategory, _crosscategory);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                int result = _license;
                result = (result*397) ^ (_lastname != null ? _lastname.GetHashCode() : 0);
                result = (result*397) ^ (_firstname != null ? _firstname.GetHashCode() : 0);
                result = (result*397) ^ (_city != null ? _city.GetHashCode() : 0);
                result = (result*397) ^ (_state != null ? _state.GetHashCode() : 0);
                result = (result*397) ^ (_gender != null ? _gender.GetHashCode() : 0);
                result = (result*397) ^ (_racingage != null ? _racingage.GetHashCode() : 0);
                result = (result*397) ^ (_expdate != null ? _expdate.GetHashCode() : 0);
                result = (result*397) ^ (_club != null ? _club.GetHashCode() : 0);
                result = (result*397) ^ (_team != null ? _team.GetHashCode() : 0);
                result = (result*397) ^ (_ncaa != null ? _ncaa.GetHashCode() : 0);
                result = (result*397) ^ (_crosscategory != null ? _crosscategory.GetHashCode() : 0);
                return result;
            }
        }
    }
}